﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace Kokomo.Mirror.PeFormat
{
	public class ImportedFunction
	{
		public ImportedFunction(
			int ordinal,
			string name,
			//uint? originalThunkRva,
			uint thunkRva
			)
		{
			this.Ordinal = ordinal;
			this.DecoratedName = name;

			//this.OriginalThunkRva = originalThunkRva;
			this.ThunkRva = thunkRva;
		}

		public override string ToString()
		{
			if (this.DecoratedName != null)
			{
				return string.Format("{0} @ {1}", this.DecoratedName, this.Ordinal);
			}
			else
			{
				return string.Format("#{0}", this.Ordinal);
			}
		}

		public int Ordinal { get; private set; }

		//[DisplayName("Original thunk RVA")]
		//[TypeConverter(typeof(HexConverter))]
		//public uint? OriginalThunkRva { get; private set; }

		[DisplayName("Thunk RVA")]
		[TypeConverter(typeof(HexConverter))]
		public uint ThunkRva { get; private set; }

		[DisplayName("Decorated name")]
		public string DecoratedName { get; private set; }

		[DisplayName("Undecorated name")]
		public string UndecoratedName
		{
			get
			{
				if (this.DecoratedName == null) return null;
				return DebugHelper.UndecorateSymbolName(this.DecoratedName);
			}
		}
	}
}
